{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "import matplotlib.pyplot as plt\n",
    "from math import *\n",
    "import numpy as np"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 26,
   "metadata": {},
   "outputs": [],
   "source": [
    "interval = 0.001"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 27,
   "metadata": {},
   "outputs": [],
   "source": [
    "# 3x3 memristor crossbar\n",
    "# 전압으로 MEMRISTOR 저\n",
    "class Memristor:\n",
    "    def __init__(self, name):\n",
    "        self.name = name\n",
    "        self.x = 0.1\n",
    "        self.xp = 0.1\n",
    "        self.xn = 0.2\n",
    "        self.vp = 1.5\n",
    "        self.vn = 0.7\n",
    "        self.alphap = 6\n",
    "        self.alphan = 4\n",
    "        self.a1 = 4e-4\n",
    "        self.a2 = 3e-4\n",
    "        self.ap = 0.032\n",
    "        self.an = 0.001\n",
    "        self.b = 1.0\n",
    "        \n",
    "        self.gf = 0.0\n",
    "        \n",
    "        self.interval = 0.001\n",
    "    \n",
    "    def change_x(self, V):\n",
    "        if V >= 0:\n",
    "            if self.x >= self.xp:\n",
    "                self.f = exp(-self.alphap*(self.x - self.xp)) * (((self.xp - self.x)/(1 - self.xp)) + 1)\n",
    "            else:\n",
    "                self.f = 1.0\n",
    "        elif V < 0:\n",
    "            if self.x <= (1 - self.xn):\n",
    "                self.f = exp(self.alphan*(self.x + self.xn - 1.0)) * (self.x/(1-self.xn))\n",
    "            else:\n",
    "                self.f = 1.0\n",
    "            \n",
    "        if V > self.vp:\n",
    "            self.g = self.ap * (exp(V)-exp(self.vp))\n",
    "        elif V < -self.vn:\n",
    "            self.g = -self.an * (exp(-V)-exp(self.vn))\n",
    "        else:\n",
    "            self.g = 0\n",
    "            \n",
    "        self.gf = self.f * self.g\n",
    "        self.x += self.gf * self.interval\n",
    "    \n",
    "    def activate(self, V):\n",
    "        self.change_x(V)\n",
    "        \n",
    "        if V >= 0:\n",
    "            curr = self.a1 * self.x * sinh(self.b * V)\n",
    "        else:\n",
    "            curr = self.a2 * self.x * sinh(self.b * V)\n",
    "        \n",
    "        self.resistance = V / curr\n",
    "        \n",
    "        return curr"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 30,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[[ 0. -1.  0.]\n",
      " [ 0.  0.  0.]\n",
      " [ 1. -1.  1.]]\n"
     ]
    }
   ],
   "source": [
    "w = (x-t)/2\n",
    "print(w)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "   # 제대로"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 64,
   "metadata": {},
   "outputs": [],
   "source": [
    "w = np.array([[0.5,0.2,0.5],\n",
    "             [0.5,0.2,0.5],\n",
    "             [1.0,0.2,1.0],\n",
    "             [0.5,0.5,1.0],\n",
    "             [0.2,0.2,0.2],\n",
    "             [1.0,1.0,0.2]])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 65,
   "metadata": {},
   "outputs": [],
   "source": [
    "w = w.reshape(9,2)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 66,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[[0.5 0.2]\n",
      " [0.5 0.5]\n",
      " [0.2 0.5]\n",
      " [1.  0.2]\n",
      " [1.  0.5]\n",
      " [0.5 1. ]\n",
      " [0.2 0.2]\n",
      " [0.2 1. ]\n",
      " [1.  0.2]]\n"
     ]
    }
   ],
   "source": [
    "print(w)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 67,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<matplotlib.image.AxesImage at 0x7fb0335c15c0>"
      ]
     },
     "execution_count": 67,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAOUAAAOfCAYAAAA3mAQsAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDIuMS4yLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvNQv5yAAAEttJREFUeJzt212MpndZx/Hrcmf7toJIrSBtI02EJg3hxUyqFmMiFSlq4MSDNmKiIdkDg1I1IXhEPDXG4AGabBAxsZYgQkIIUghCGgJUhlK0pWBq5aWF2lKiwFL7sl4edDCl3TrPpnPP/OT+fJJNd2b+e/eXTL+573n2ac9MATl+4LAHAN9LlBBGlBBGlBBGlBBGlBBGlKfR3Vd19xe6+47ufuNh71mr7n5bd9/b3bce9paDJMrH6e4jVfWWqnplVV1WVdd092WHu2q13l5VVx32iIMmyie6vKrumJk7Z+ahqnpHVb36kDet0szcWFXfOOwdB02UT3RhVX3lMR/ftfs5OBCihDCifKK7q+rix3x80e7n4ECI8ok+VVXP6+5Luvusqrq6qt57yJtYEVE+zsw8UlWvq6obqur2qnrnzNx2uKvWqbuvr6pPVNWl3X1Xd7/2sDcdhPa/bkEWd0oII0oII0oII0oII0oII8on0d3HD3sDj1rb90KUT25V/yGEW9X3QpQQZpE3D2yde2yOPv2Z+37dg3TqgZN15Nxjhz3jKTt678nDnvCUPVwP1tE6+7BnPGX/VSfroXmw9zq3tcS//OjTn1k/8Wu/t8SlOUPPfvPHD3sCu26aD290zuMrhBElhBElhBElhBElhBElhBElhBElhBElhBElhBElhBElhBElhBElhBElhBElhBElhBElhBElhBElhBElhBElhBElhBElhBElhBElhBElhBElhBElhBElhBElhBElhBElhBElhBElhBElhBElhBElhBElhBElhBElhBElhBElhBElhNkoyu6+qru/0N13dPcblx4Fa7ZnlN19pKreUlWvrKrLquqa7r5s6WGwVpvcKS+vqjtm5s6Zeaiq3lFVr152FqzXJlFeWFVfeczHd+1+7nt09/Hu3ununVMPnNyvfbA6+/ZCz8ycmJntmdk+cu6x/bosrM4mUd5dVRc/5uOLdj8HLGCTKD9VVc/r7ku6+6yqurqq3rvsLFivrb0OzMwj3f26qrqhqo5U1dtm5rbFl8FK7RllVdXMvL+q3r/wFqC8owfiiBLCiBLCiBLCiBLCiBLCiBLCiBLCiBLCiBLCiBLCiBLCiBLCiBLCiBLCiBLCiBLCiBLCiBLCiBLCiBLCiBLCiBLCiBLCiBLCiBLCiBLCiBLCiBLCiBLCiBLCiBLCiBLCiBLCiBLCiBLCiBLCiBLCiBLCiBLCiBLCiBLCiBLCbB32AJZ1z7VXHPYEdj183Sc3OudOCWFECWFECWFECWFECWFECWFECWFECWFECWFECWFECWFECWFECWFECWFECWFECWFECWFECWFECWFECWFECWFECWFECWFECWFECWFECWFECWFECWFECWFECWFECWFECWFECWFECWFECWFECWFECWFECWFECWFECWFECWFECWFECWFECWFECWFECWH2jLK739bd93b3rQcxCNZukzvl26vqqoV3ALv2jHJmbqyqbxzAFqD28WfK7j7e3TvdvXPqgZP7dVlYnX2LcmZOzMz2zGwfOffYfl0WVserrxBGlBBmk78Sub6qPlFVl3b3Xd392uVnwXpt7XVgZq45iCHAozy+QhhRQhhRQhhRQhhRQhhRQhhRQhhRQhhRQhhRQhhRQhhRQhhRQhhRQhhRQhhRQhhRQhhRQhhRQhhRQhhRQhhRQhhRQhhRQhhRQhhRQhhRQhhRQhhRQhhRQhhRQhhRQhhRQhhRQhhRQhhRQhhRQhhRQhhRQhhRQhhRQhhRQhhRQpitJS569N6T9ew3f3yJS3OG7rn2isOewBlyp4QwooQwooQwooQwooQwooQwooQwooQwooQwooQwooQwooQwooQwooQwooQwooQwooQwooQwooQwooQwooQwooQwooQwooQwooQwooQwooQwooQwooQwooQwooQwooQwooQwooQwooQwooQwooQwooQwooQwooQwooQwooQwooQwooQwooQwooQwe0bZ3Rd390e6+3PdfVt3v/4ghsFabW1w5pGq+v2Zubm7n1ZVn+7uD83M5xbeBqu0551yZr42Mzfv/v5bVXV7VV249DBYqzP6mbK7n1tVL6mqm5YYA2z2+FpVVd39g1X1d1V17cx88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hRAlhRAlhRAlhRAlhRAlhRAlhRAlhRAlhRAlhRAlhRAlhRAlhRAlhRAlhRAlhRAlhRAlhRAlhRAlhRAlhRAlhRAlhRAlhRAlhRAlhRAlhRAlhRAlhRAlhRAlhRAlhRAlhRAlhRAlhRAlhRAlhRAlhRAlhRAlhRAlhtpa46PNf+J264YZblrg0Z+gVz3nxYU9g17/M/Rudc6eEMKKEMKKEMKKEMKKEMKKEMKKEMKKEMKKEMKKEMKKEMKKEMKKEMKKEMKKEMKKEMKKEMKKEMKKEMKKEMKKEMKKEMKKEMKKEMKKEMKKEMKKEMKKEMKKEMKKEMKKEMKKEMKKEMKKEMKKEMKKEMKKEMKKEMKKEMKKEMKKEMKKEMKKEMKKEMKKEMBtF2d2/2923dfet3X19d5+z9DBYqz2j7O4Lq+p3qmp7Zl5QVUeq6uqlh8Fabfr4ulVV53b3VlWdV1VfXW4SrNueUc7M3VX1x1X15ar6WlX958x8cOlhsFabPL7+cFW9uqouqarnVNWx7n7Nac4d7+6d7t657/5T+78UVmKTx9dfqKp/m5n7Zubhqnp3VV3x+EMzc2Jmtmdm+4Lzj+z3TliNTaL8clX9dHef191dVVdW1e3LzoL12uRnypuq6l1VdXNV/fPunzmx8C5Yra1NDs3Mm6rqTQtvAco7eiCOKCGMKCGMKCGMKCGMKCGMKCGMKCGMKCGMKCGMKCGMKCGMKCGMKCGMKCGMKCGMKCGMKCGMKCGMKCGMKCGMKCGMKCGMKCGMKCGMKCGMKCGMKCGMKCGMKCGMKCGMKCGMKCGMKCGMKCGMKCGMKCGMKCGMKCGMKCGMKCGMKCGMKCGMKCFMz8z+X7T7vqr60r5f+GD9SFV9/bBHUFXfP9+LH5+ZC/Y6tEiU3w+6e2dmtg97B+v7Xnh8hTCihDCifHInDnsA/2tV3ws/U0IYd0oII0oII0oII0oII0oI8z+wuFtScN1rCwAAAABJRU5ErkJggg==\n",
      "text/plain": [
       "<matplotlib.figure.Figure at 0x7fb033635518>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "plt.matshow(w)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 68,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "9"
      ]
     },
     "execution_count": 68,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "len(w)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 69,
   "metadata": {},
   "outputs": [],
   "source": [
    "V = 1.7\n",
    "def mapping(w):\n",
    "    output = []\n",
    "    \n",
    "    for i in range(len(w)):\n",
    "        for j in range(len(w[0])):\n",
    "            exec('mem_%d%d = Memristor(\"mem_%d%d\")'%(i,j,i,j))\n",
    "            \n",
    "    for i, row in enumerate(w):\n",
    "        out_row = []\n",
    "        for j, t  in enumerate(row):\n",
    "            for time in np.arange(0,t,0.001):\n",
    "                exec('mem_%d%d.activate(V)'%(i,j))\n",
    "            \n",
    "            exec('out_row.append(mem_%d%d.x)'%(i,j))\n",
    "        output.append(out_row)\n",
    "    \n",
    "    return np.array(output)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 70,
   "metadata": {},
   "outputs": [],
   "source": [
    "a = mapping(w)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 71,
   "metadata": {
    "scrolled": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[[0.115043   0.10621186]\n",
      " [0.115043   0.115043  ]\n",
      " [0.10621186 0.115043  ]\n",
      " [0.12862764 0.10621186]\n",
      " [0.12862764 0.115043  ]\n",
      " [0.115043   0.12862764]\n",
      " [0.10621186 0.10621186]\n",
      " [0.10621186 0.12862764]\n",
      " [0.12862764 0.10621186]]\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "<matplotlib.image.AxesImage at 0x7fb0334d2f98>"
      ]
     },
     "execution_count": 71,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAOUAAAOfCAYAAAA3mAQsAAA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qq4c9gqr67vle/OjMnL/XoUWi/G7Q3Tszs33YO1jf98LjK4QRJYQR5RM7cdgD+F+r+l74mRLCuFNCGFFCGFFCGFFCGFFCmP8BGNxbTcALKBMAAAAASUVORK5CYII=\n",
      "text/plain": [
       "<matplotlib.figure.Figure at 0x7fb033510978>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "print(a)\n",
    "plt.matshow(a)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 73,
   "metadata": {},
   "outputs": [],
   "source": [
    "X = np.array([[1,0,1],[0,1,0],[1,0,1]])\n",
    "T = np.array([[1,1,1],[0,1,0],[0,1,0]])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 74,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[[1 0 1]\n",
      " [0 1 0]\n",
      " [1 0 1]] \n",
      "\n",
      "[[1 1 1]\n",
      " [0 1 0]\n",
      " [0 1 0]]\n"
     ]
    }
   ],
   "source": [
    "print(X, '\\n')\n",
    "print(T)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 75,
   "metadata": {},
   "outputs": [],
   "source": [
    "X = X.reshape(1,9)\n",
    "T = T.reshape(1,9)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 76,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[[2.9 1.6]] [[2.4 2.7]]\n"
     ]
    }
   ],
   "source": [
    "output1 = np.dot(X,w)\n",
    "output2 = np.dot(T,w)\n",
    "\n",
    "print(output1, output2)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.2"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
